package com.wnxy.pawnbackgroundsystem.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wnxy.pawnbackgroundsystem.entity.GoodsImg;
import com.wnxy.pawnbackgroundsystem.param.goodsParam.GoodsParam;
import com.wnxy.pawnbackgroundsystem.response.Result;
import com.wnxy.pawnbackgroundsystem.service.IGoodsImgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/goodsImg")
@Slf4j
@CrossOrigin("*")
public class GoodsImgController {

    @Resource
    private IGoodsImgService goodsImgService;

    @GetMapping("/getGoodsImg")
    public Result getGoodsImg(GoodsParam goodsParam,
                              @RequestParam(name = "pageSize",defaultValue = "10") int pageSize
            , @RequestParam(name = "current",defaultValue = "1") int current){
        log.info("查询图片功能：参数={},{},{}",goodsParam.getGoodsId(),pageSize,current);
        if (null == goodsParam.getGoodsId()){
            return Result.checkFail("没有商品参数");
        }
        IPage goodsImgs = goodsImgService.getGoodsImgByGoodsId(goodsParam.getGoodsId(),current,pageSize);
        return Result.success(GoodsImg.class,goodsImgs);
    }
}
